{% extends 'base.html' %}
{% load static %}

{% block title %}{{ activity.title }} - 参与者列表 - Meet活动聚{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-12">
            <div class="card shadow">
                <div class="card-header bg-info text-white">
                    <h4 class="mb-0"><i class="bi bi-people"></i> 活动参与者列表</h4>
                </div>
                <div class="card-body">
                    <div class="mb-4">
                        <h5>活动信息</h5>
                        <p><strong>活动标题：</strong>{{ activity.title }}</p>
                        <p><strong>活动时间：</strong>{{ activity.start_time|date:"Y-m-d H:i" }} - {{ activity.end_time|date:"Y-m-d H:i" }}</p>
                        <p><strong>活动地点：</strong>{{ activity.location }}</p>
                        <p><strong>参与人数：</strong>{{ registrations|length }}/{{ activity.max_participants }}</p>
                    </div>

                    <h5>参与者列表</h5>
                    {% if registrations %}
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>用户名</th>
                                    <th>昵称</th>
                                    <th>报名时间</th>
                                    <th>签到状态</th>
                                    <th>签到时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for reg in registrations %}
                                <tr>
                                    <td>{{ reg.user.username }}</td>
                                    <td>{{ reg.user.nickname|default:"未设置" }}</td>
                                    <td>{{ reg.created_at|date:"Y-m-d H:i" }}</td>
                                    <td>
                                        {% if reg.is_checked_in %}
                                        <span class="badge bg-success">已签到</span>
                                        {% else %}
                                        <span class="badge bg-warning">未签到</span>
                                        {% endif %}
                                    </td>
                                    <td>{{ reg.checked_in_at|date:"Y-m-d H:i"|default:"未签到" }}</td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    {% else %}
                    <p class="text-muted">暂无参与者</p>
                    {% endif %}

                    <div class="mt-4">
                        <a href="{% url 'activities:activity_detail' activity.id %}" class="btn btn-primary">
                            <i class="bi bi-arrow-left"></i> 返回活动详情
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}